package org.drools.controller;

import org.drools.model.Order;
import org.drools.model.Order2;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.web.bind.annotation.GetMapping;
import org.springframework.web.bind.annotation.RestController;

@RestController
public class HelloController {
    @Autowired
    private DroolsService droolsService;

    @GetMapping("/hello")
    public String hello() {
        return "success";
    }

    @GetMapping("/droolsOrderTest")
    public void droolsOrderTest() {
        // 1-规则引擎处理逻辑
        Order2 order2 = Order2.builder().amount(1000).build();
        droolsService.fireAllRules(order2);
        Order order = Order.builder().amount(1000).build();
        droolsService.fireAllRules(order);
        // 2-执行完规则后, 执行相关的逻辑
        System.out.println(order);
        System.out.println(order2);
    }
}
